# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libvorbisidec

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-svn"
_revision=
_fragment=
[[ -n ${_revision} ]] && _fragment="#revision=${_revision}"
pkgver=r19083
pkgrel=1
pkgdesc='Integer-only Ogg Vorbis decoder, AKA \"tremor\" (mingw-w64)'
arch=('any')
url='http://svn.xiph.org/trunk/Tremor'
license=('custom')
groups=("${MINGW_PACKAGE_PREFIX}")
depends=("${MINGW_PACKAGE_PREFIX}-libogg")
makedepends=("subversion" "${MINGW_PACKAGE_PREFIX}-gcc")
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}")
options=('strip' 'staticlibs' '!emptydirs')
source=("${_realname}"::"svn+http://svn.xiph.org/trunk/Tremor/${_fragment}"
    0001-add-no-undefined-for-libtool.mingw.patch
    0002-no-configure-in-autogen.mingw.patch
    0003-update-ac.mingw.patch)
md5sums=('SKIP'
         '80093e985a7229560dfe67ffbc5a5257'
         '7bc4664533cfc396e55c951d012c24a8'
         '43fba0fb6b12e663841c40f8e4f5fc4f')

pkgver() {
  cd "$srcdir/${_realname}"
  local ver="$(svnversion)"
  printf "r%s" "${ver//[[:alpha:]]}"
}

prepare() {
  cd ${srcdir}/${_realname}
  patch -p1 -i ${srcdir}/0001-add-no-undefined-for-libtool.mingw.patch
  patch -p1 -i ${srcdir}/0002-no-configure-in-autogen.mingw.patch
  patch -p1 -i ${srcdir}/0003-update-ac.mingw.patch

  ./autogen.sh
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
    ${srcdir}/${_realname}/configure \
    --prefix=${MINGW_PREFIX}/${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
        --target=${MINGW_CHOST}
    make
}

package() {
    cd ${srcdir}/build-${MINGW_CHOST}
    make DESTDIR=${pkgdir} install
}

